<?php 
header("Content-type: text/xml");

require_once 'settings.php';
// $con = mysql_connect('localhost', 'root', 'super');
// if (!$con)
//   {
//   die('Could not connect: ' . mysql_error());
//   }

// mysql_select_db("db_tursib", $con);
 

$sql="SELECT hour,bus_name FROM t_hours as a join t_busses as b  on 
           				 a.t_busses_id_bus = b.id_bus 
            WHERE t_busses_id_bus ='".$_GET['id_bus']."' 
            	and t_stations_id_station='".$_GET['id_station']."' 
            		and t_days_id_day='".$_GET['id_day']."' and 
                         hour > subtime(convert('".$_GET['hour']."',TIME),maketime(0,10,0)) and
                         hour < addtime(convert('".$_GET['hour']."',TIME),maketime(0,45,0)) LIMIT 3";


$result = mysql_query($sql);
 
//Build Result String
$data = "<?xml version='1.0' encoding='UTF-8'?><xml>" ;
 

// Insert a new row in the table for each person returned
 
while($row = mysql_fetch_array($result)){
	$data .= "<item>";
	$data .= "<hour>$row[hour]</hour>";
	$data .= "<bus>$row[bus_name]</bus>";
	$data .= "</item>";

} 
$data .="</xml>";
echo $data;  

mysql_close($con);
?>